package encrypt;

public class Test {
    public static void main(String[] args) {
        String str = "PBE";
        String password = "123";

        System.out.println("明文: " + str);
        System.out.println("密码: " + password);

        try {
            //随机生成一个盐值
            String salt = PasswordUtil.getRandomString();
            System.out.println(salt);

            String ciphertext = PasswordUtil.encrypt(str, password, salt);
            System.out.println("密文:" + ciphertext);

            String plaintext = PasswordUtil.decrypt(ciphertext, password, salt);
            System.out.println("明文:" + plaintext);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
